home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_qt.idb / usr / freeware / include / Qt / qbutton.h.z / qbutton.h
Encoding:
C/C++ Source or Header  |  1998-10-28  |  3.3 KB  |  156 lines

  1. /****************************************************************************
  2. ** $Id: qbutton.h,v 2.18 1998/07/03 00:09:47 hanord Exp $
  3. **
  4. ** Definition of QButton widget class
  5. **
  6. ** Created : 940206
  7. **
  8. ** Copyright (C) 1992-1998 Troll Tech AS.  All rights reserved.
  9. **
  10. ** This file is part of Qt Free Edition, version 1.40.
  11. **
  12. ** See the file LICENSE included in the distribution for the usage
  13. ** and distribution terms, or http://www.troll.no/free-license.html.
  14. **
  15. ** IMPORTANT NOTE: You may NOT copy this file or any part of it into
  16. ** your own programs or libraries.
  17. **
  18. ** Please see http://www.troll.no/pricing.html for information about 
  19. ** Qt Professional Edition, which is this same library but with a
  20. ** license which allows creation of commercial/proprietary software.
  21. **
  22. *****************************************************************************/
  23.  
  24. #ifndef QBUTTON_H
  25. #define QBUTTON_H
  26.  
  27. #ifndef QT_H
  28. #include "qwidget.h"
  29. #endif // QT_H
  30.  
  31.  
  32. class QButtonGroup;                // button group (qbuttongroup.h)
  33. struct QButtonData;
  34.  
  35.  
  36. class QButton : public QWidget            // button class
  37. {
  38.     Q_OBJECT
  39. public:
  40.     QButton( QWidget *parent=0, const char *name=0 );
  41.    ~QButton();
  42.  
  43.     const char *text() const;
  44.     void    setText( const char * );
  45.     const QPixmap *pixmap() const;
  46.     void    setPixmap( const QPixmap & );
  47.  
  48.     int        accel()    const;
  49.     void    setAccel( int );
  50.  
  51.     bool    isToggleButton() const;
  52.  
  53.     void    setDown( bool );
  54.     bool    isDown() const;
  55.  
  56.     bool    isOn() const;
  57.  
  58.     bool    autoResize() const;
  59.     void    setAutoResize( bool );
  60.  
  61.     bool    autoRepeat() const;
  62.     void    setAutoRepeat( bool );
  63.  
  64. public slots:
  65.     void    animateClick();
  66.     void    toggle();
  67.  
  68. signals:
  69.     void    pressed();
  70.     void    released();
  71.     void    clicked();
  72.     void    toggled( bool );
  73.  
  74. protected:
  75.     void    setToggleButton( bool );
  76.     void    setOn( bool );
  77.  
  78.     virtual bool hitButton( const QPoint &pos ) const;
  79.     virtual void drawButton( QPainter * );
  80.     virtual void drawButtonLabel( QPainter * );
  81.  
  82.     void    keyPressEvent( QKeyEvent *);
  83.     void    mousePressEvent( QMouseEvent * );
  84.     void    mouseReleaseEvent( QMouseEvent * );
  85.     void    mouseMoveEvent( QMouseEvent * );
  86.     void    paintEvent( QPaintEvent * );
  87.     void    focusInEvent( QFocusEvent * );
  88.     void    focusOutEvent( QFocusEvent * );
  89.  
  90.     void    enabledChange( bool );
  91.  
  92. private slots:
  93.     void    animateTimeout();
  94.     void    autoRepeatTimeout();
  95.  
  96. private:
  97.     QString    btext;
  98.     QPixmap    *bpixmap;
  99.     uint    toggleBt    : 1;
  100.     uint    buttonDown    : 1;
  101.     uint    buttonOn    : 1;
  102.     uint    mlbDown        : 1;
  103.     uint    autoresize    : 1;
  104.     uint    animation    : 1;
  105.     uint    repeat        : 1;
  106.     QButtonData *d;
  107.  
  108.     friend class QButtonGroup;
  109.     void          ensureData();
  110.     QButtonGroup *group() const;
  111.     void      setGroup( QButtonGroup* );
  112.     QTimer     *timer();
  113. private:    // Disabled copy constructor and operator=
  114.     QButton( const QButton & );
  115.     QButton &operator=( const QButton & );
  116. };
  117.  
  118.  
  119. inline const char *QButton::text() const
  120. {
  121.     return btext;
  122. }
  123.  
  124. inline const QPixmap *QButton::pixmap() const
  125. {
  126.     return bpixmap;
  127. }
  128.  
  129. inline bool QButton::isToggleButton() const
  130. {
  131.     return toggleBt;
  132. }
  133.  
  134. inline  bool QButton::isDown() const
  135. {
  136.     return buttonDown;
  137. }
  138.  
  139. inline bool QButton::isOn() const
  140. {
  141.     return buttonOn;
  142. }
  143.  
  144. inline bool QButton::autoResize() const
  145. {
  146.     return autoresize;
  147. }
  148.  
  149. inline bool QButton::autoRepeat() const
  150. {
  151.     return repeat;
  152. }
  153.  
  154.  
  155. #endif // QBUTTON_H
  156.